# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=mkvtoolnix
pkgver=49.0.0
pkgrel=0
pkgdesc="Set of tools to create, edit and inspect Matroska files"
url="https://mkvtoolnix.download/index.html"
arch="all !armhf" # qtmultimedia -> qtdeclarative
license="GPL-2.0-only"
makedepends="boost-dev docbook-xsl file-dev flac-dev gtest-dev
	libmatroska-dev libogg-dev libvorbis-dev ruby-json ruby-rake zlib-dev
	qt5-qtbase-dev qt5-qtmultimedia-dev cmark-dev"
subpackages="$pkgname-doc $pkgname-gui"
source="https://mkvtoolnix.download/sources/$pkgname-$pkgver.tar.xz"

build() {
	./configure CC="${CC:-gcc}" CFLAGS="${CFLAGS}" \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--without-gettext
	rake V=1 -j${JOBS}
}

check() {
	rake V=1 -j${JOBS} tests:unit
	rake V=1 -j${JOBS} tests:run_unit
}

package() {
	rake DESTDIR="$pkgdir" install
}

gui() {
	pkgdesc="$pkgdesc (GUI)"
	depends="$pkgname qt5-qtmultimedia"

	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/mkvtoolnix-gui "$subpkgdir"/usr/bin/
	mv "$pkgdir"/usr/share "$subpkgdir"/usr/
}

sha512sums="087638abea16639d4c452639617d0a183b58bf0496b1c150a46b80a50c15c4a4e9926437dfe002e7f574bd2b72b1e0cf810838c476dd7816bad86ed026e5f4c7  mkvtoolnix-49.0.0.tar.xz"
